/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { getUserInfo } from "../services/user";

export default {
  namespace: "user",

  state: {
    currentUser: {},
  },

  effects: {
    *updateCurrentUser({ payload }, { put, select }) {
      const { currentUser } = yield select(_ => _.user);
      const updateData = {
        ...currentUser,
        ...payload,
      };
      yield put({
        type: "saveCurrentUser",
        payload: {
          currentUser: updateData,
        },
      });
    },
  },

  reducers: {
    saveCurrentUser(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
